import axios from 'axios';
import { Pagination, PaginationData } from '@/types/global';

export interface UserGroupListParams extends Pagination {
  name: string;
}

export interface UserGroupVo {
  id: string;
  name: string;
  sortNumber?: string;
  status?: string;
  type?: string;
}

export function selectPageUserGroup(params: UserGroupListParams) {
  return axios.post<PaginationData<UserGroupVo>>(
    'tenant/userGroup/findPageUserGroups',
    params
  );
}

export function createUserGroup(params: UserGroupVo) {
  return axios.post<UserGroupVo>('tenant/userGroup/createUserGroup', params);
}

export function updateUserGroup(params: UserGroupVo) {
  return axios.post<UserGroupVo>('tenant/userGroup/updateUserGroup', params);
}

export function delUserGroup(id: string) {
  return axios.get<string>(`tenant/userGroup/deleteUserGroup?id=${id}`);
}
export interface UserGroupVO {
  id: string;
}
// 根据菜单id查询绑定的用户组
export function selectUserGroupByBindMenu(menuId: string) {
  return axios.post<UserGroupVO[]>(
    `tenant/userGroup/selectUserGroupByBindMenu?menuId=${menuId}`
  );
}
// 根据组织id查询绑定的用户组
export function selectUserGroupByBindOrganization(orgId: string) {
  return axios.post<UserGroupVO[]>(
    `tenant/userGroup/selectUserGroupByBindOrganization?orgId=${orgId}`
  );
}
